package com.miaomi.Service.impl;

import com.miaomi.Bean.Tel_sys;
import com.miaomi.Dao.impl.TelephoneDaoImpl;
import com.miaomi.Service.TelephoneService;

import java.util.Collections;
import java.util.List;

public class TelephoneServiceImpl implements TelephoneService {
    TelephoneDaoImpl telephoneDao = new TelephoneDaoImpl();
    @Override
    public boolean InsertTel(Tel_sys t) {
        return telephoneDao.insert(t) == 1 ? true :false;
    }

    @Override
    public boolean DeleteTel(Integer id) {
        if (telephoneDao.selectId(id) == null){
            return false;
        }
        return telephoneDao.delete(id) == 1 ? true :false;
    }

    @Override
    public boolean UpdateTel(Tel_sys t) {
        if (telephoneDao.selectId(t.getId()) == null){
            return false;
        }
        return telephoneDao.update(t) == 1 ? true :false;
    }

    @Override
    public List<Tel_sys> SelectAll() {
        return telephoneDao.selectAll();
    }

    @Override
    public List<Tel_sys> SelectName(String name) {
        return telephoneDao.selectName(name);
    }

    @Override
    public List<Tel_sys> SelectId(Integer id) {
        return telephoneDao.selectId(id);
    }
}
